using System;

namespace Touchmax
{
	public class OpOrder
	{
		private int oid;
		private string jobNo;
		private string custId;
		private DateTime jobDate;
		private string jobSource;
		private string jobType;
		private string tehnician;
		private string custContact;
		private string jobStatus;
		private string remark;
		private string userId;
		private DateTime entryDate;
		private decimal amount;

		public int Oid
		{
			get { return this.oid; }
		}

		public string JobNo
		{
			get { return this.jobNo; }
			set { this.jobNo = value; }
		}

		public string CustId
		{
			get { return this.custId; }
			set { this.custId = value; }
		}

        public string CustName
        {
            get
            {
                string s = "";
                if (this.CustId != null)
                {
                    string sql = "select name from BoClient where CustId='" + SafeValue.SafeInt(this.custId, 0) + "'";
                    s = SafeValue.SafeString(Touchmax.Manager.ORManager.ExecuteScalar(sql), "");
                }
                return s;
            }
        }

        public string Latitude
        {
            get
            {
                string s = "";
                if (this.CustId != null)
                {
                    string sql = "select latitude from BoClient where CustId='" + SafeValue.SafeInt(this.custId, 0) + "'";
                    s = SafeValue.SafeString(Touchmax.Manager.ORManager.ExecuteScalar(sql), "");
                }
                return s;
            }
        }

        public string Longitude
        {
            get
            {
                string s = "";
                if (this.CustId != null)
                {
                    string sql = "select longitude from BoClient where CustId='" + SafeValue.SafeInt(this.custId, 0) + "'";
                    s = SafeValue.SafeString(Touchmax.Manager.ORManager.ExecuteScalar(sql), "");
                }
                return s;
            }
        }


		public DateTime JobDate
		{
			get { return this.jobDate; }
			set { this.jobDate = value; }
		}

		public string JobSource
		{
			get { return this.jobSource; }
			set { this.jobSource = value; }
		}

		public string JobType
		{
			get { return this.jobType; }
			set { this.jobType = value; }
		}

		public string Tehnician
		{
			get { return this.tehnician; }
			set { this.tehnician = value; }
		}

		public string CustContact
		{
			get { return this.custContact; }
			set { this.custContact = value; }
		}

		public string JobStatus
		{
			get { return this.jobStatus; }
			set { this.jobStatus = value; }
		}

		public string Remark
		{
			get { return this.remark; }
			set { this.remark = value; }
		}

		public string UserId
		{
			get { return this.userId; }
			set { this.userId = value; }
		}

		public DateTime EntryDate
		{
			get { return this.entryDate; }
			set { this.entryDate = value; }
		}

        public decimal Amount
        {
            get
            {
                decimal amt = 0;
                if (this.jobNo != null && this.jobNo.Length > 0)
                {
                    string sql = "select sum(totamt) from opinvoicedet where joborder='" + this.jobNo + "'";
                    amt = SafeValue.SafeDecimal(Touchmax.Manager.ORManager.ExecuteScalar(sql), 0);
                }
                return amt;
            }
        }
	}
}
